            

const sha1 = 'f02958aebb2bb1f7c370b1261ceef5231a8da0d4'
const md5 = '35168d8b62cc445d2bb6952a54e38fa3'
/**  
 * 检查安卓APK签名  
 * @param {String} type 签名指纹类型:MD5或SHA1  
 */  
export const checkApkSign = (type) => {  
    //获取应用上下文  
    var context = plus.android.runtimeMainActivity();  
    var PackageManager = plus.android.importClass("android.content.pm.PackageManager");  
    var packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(),PackageManager.GET_SIGNING_CERTIFICATES||PackageManager.GET_SIGNATURES)  
    var Build = plus.android.importClass("android.os.Build");  
    var signatures = null;  
    //Android 28以后获取包签名信息方法改了  
    if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P){  
        var signingInfo = packageInfo.plusGetAttribute('signingInfo');  
        signatures = plus.android.invoke(signingInfo,"getApkContentsSigners")  
    }else{  
        signatures = packageInfo.plusGetAttribute('signatures');  
    }  
    if (signatures != null) {  
        var byteArr;  
        var currentSignature;  
        var md = plus.android.invoke("java.security.MessageDigest","getInstance",type);  
        for (var i in signatures) {  
            byteArr=plus.android.invoke(signatures[i],"toByteArray");  
            plus.android.invoke(md,"update",byteArr);  
            currentSignature = Bytes2HexString(plus.android.invoke(md,"digest")).toUpperCase();  
            //根据检验类型，与与你签名文件对应的签名值比对  
			console.log(currentSignature)
            if(("SHA1"== type && sha1.toUpperCase()==currentSignature) || ("MD5"==type && md5.toUpperCase()==currentSignature)){
				console.log('签名验证成功')
                return true;
            }
        }
    } else {  
        console.info("应用未签名");
    }
    return false;  
}
//字节数组转十六进制字符串，对负值填坑  
function Bytes2HexString(arrBytes) {  
  var str = "";  
  for (var i = 0; i < arrBytes.length; i++) {  
    var tmp;  
    var num=arrBytes[i];  
    if (num < 0) {  
    //此处填坑，当byte因为符合位导致数值为负时候，需要对数据进行处理  
      tmp =(255+num+1).toString(16);  
    } else {  
      tmp = num.toString(16);  
    }  
    if (tmp.length == 1) {  
      tmp = "0" + tmp;  
    }  
    str += tmp;  
  }  
  return str;  
}